import mockApi from "@/api/mockApi";

export default class workExperienceApi {
  static workExperiences = [
    {"id":1,"candidateId":2,"candidateName":"陈静","company":"阿里巴巴集团","position":"产品经理","startDate":"2015-07-01","endDate":"2018-06-30","responsibilities":"负责电商平台产品规划与设计，协调开发团队完成产品迭代，提升用户体验","createTime":"2024-02-01 22:24:11","modifyTime":"2024-07-01 22:24:11"},
    {"id":2,"candidateId":2,"candidateName":"陈静","company":"腾讯科技","position":"高级产品经理","startDate":"2018-07-01","endDate":"2021-09-30","responsibilities":"负责社交产品线的战略规划与执行，推动产品创新与用户增长","createTime":"2024-11-25 22:24:11","modifyTime":"2024-07-03 22:24:11"},
    {"id":3,"candidateId":3,"candidateName":"张伟","company":"百度公司","position":"软件开发工程师","startDate":"2012-07-01","endDate":"2015-06-30","responsibilities":"负责搜索引擎核心模块的开发与优化，提升系统性能与稳定性","createTime":"2024-11-11 22:24:11","modifyTime":"2024-04-05 22:24:11"},
    {"id":4,"candidateId":3,"candidateName":"张伟","company":"字节跳动","position":"技术主管","startDate":"2015-07-01","endDate":"2020-08-31","responsibilities":"负责推荐算法团队的技术管理，推动算法优化与业务落地","createTime":"2024-03-31 22:24:11","modifyTime":"2024-04-27 22:24:11"},
    {"id":5,"candidateId":2,"candidateName":"陈静","company":"美团点评","position":"产品总监","startDate":"2021-10-01","endDate":"2024-12-31","responsibilities":"负责本地生活服务产品的整体规划与战略实施，推动业务增长与创新","createTime":"2024-02-22 22:24:11","modifyTime":"2024-09-06 22:24:11"}
  ]

  static async save (params) {
    console.log('workExperienceApi save params', params)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }

  static async find (params) {
    console.log('workExperienceApi find params', params)
    let filteredWorkExperiences = workExperienceApi.workExperiences
    if (params.candidateId) {
      filteredWorkExperiences = workExperienceApi.workExperiences.filter(workExperience => workExperience.candidateId === params.candidateId);
    }
    const response = await mockApi.queryPageSuccessfully(filteredWorkExperiences)
    return response.data
  }

  static async findById (id) {
    console.log('workExperienceApi findById id', id)
    let target = {}
    for (let a of workExperienceApi.workExperiences) {
      if (a.id === id) {
        target = a
      }
    }
    const response = await mockApi.queryByIdSuccessfully(target)
    return response.data
  }

  static async del (id) {
    console.log('workExperienceApi del id', id)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }
}